package com.common.service.impl;

import com.alibaba.dubbo.rpc.RpcContext;
import com.common.service.CommonService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * Date 2018/07/05
 *
 * @author MT-Lin
 */
public class CommonServiceImpl implements CommonService {

    private Logger logger = LoggerFactory.getLogger(CommonServiceImpl.class);

    @Override
    public String getFromWhere(String projectName, String classReference) {
        logger.info("[Time: {}] From Project[address：{} name：{} className: {}]",
                new SimpleDateFormat("HH:mm:ss").format(new Date()),
                RpcContext.getContext().getRemoteAddress(),
                projectName,
                classReference);
        return "This is response from dubbo-demo-provider: " + RpcContext.getContext().getLocalAddress();
    }
}
